home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // Imports hungarian titles and description from port.hu site
-
- (***************************************************
- * Imports hungarian titles and description from: *
- * www.port.hu *
- * *
- * (c) 2004 Peter Varju varjupe@freemail.hu *
- * *
- * For use with Ant Movie Catalog 3.4.0 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
- program IMDb;
-
- var
- MovieName: string;
- BeginPos, EndPos: Integer;
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
-
- if pos('Nincs ilyen cφm√ film', Page.Text) <> 0 then
- showmessage('Nincs ilyen cφm√ film a PORT adatbßzisban.')
- else begin
- if pos('<center>', Page.Text) <> 0 then begin
- AnalyzeMoviePage(Page);
- end else begin
- PickTreeClear;
- AddMoviesTitles(Page,'/pls/ci/cinema.index_htm');
- if PickTreeExec(Address) then begin
- AnalyzePage(Address);
- end;
- end;
- end;
- Page.Free;
- end;
-
- procedure AnalyzeMoviePage(Page: TStringList);
- var
- Line, Temp, Value, Value2, FullValue, CommentString: string;
- LineNr: Integer;
- BeginPos, EndPos: Integer;
- begin
-
- //hungarian title
- LineNr := FindLine('<center>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('">', Line)+2;
- EndPos := pos('</font>', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- SetField(fieldTranslatedTitle, Value);
- end;
-
- //original title
- BeginPos := EndPos+1;
- Delete(Line, 1, BeginPos);
- BeginPos := pos('size="2">(', Line)+10;
- EndPos := pos(')', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- HTMLRemoveTags(Value);
- SetField(fieldOriginalTitle, Value);
-
- //year
- LineNr := FindLine('</strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('</strong>', Line)-4;
- Value := copy(Line, BeginPos, 4);
- Value2 := Copy(Value, 1, 2);
- if (Value2='19') or (Value2='20') or (Value2='21') then
- SetField(fieldYear, Value);
- end;
-
- //category, country
- LineNr := FindLine('<strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>', Line)+8;
- EndPos := pos('</strong>', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- Value := stringReverse(Value);
-
- Value2:=Value;
-
- //cutting year
- EndPos := pos(',', Value);
- Delete(Value, EndPos, Length(Value)-1);
- Value := stringReverse(Value);
- Value := Copy(trim(Value), 0, 2);
- if (Value='19') or (Value='20') or (Value='21') then
- Value2:=Copy(Value2, 7, Length(Value2));
-
- //cutting time
- Value := Value2;
- if Copy(Value,0,5)='crep ' then begin
- EndPos := pos(',', Value);
- Delete(Value, 1, EndPos);
- end;
- Value := stringReverse(Value);
-
- //cutting colors
- if pos('szφnes, fekete-fehΘr ',Value)=1 then begin
- Delete(Value, 1, 21);
- end else
- if (pos('fekete-fehΘr ',Value)=1) or (pos('szφnes ',Value)=1) then begin
- EndPos := pos(' ', Value);
- Delete(Value, 1, EndPos);
- end;
-
- //cutting language type
- if (pos('magyarul beszΘl⌡ ',Value)=1) then begin
- Delete(Value, 1, 17);
- end;
- if (pos('hangalßmondßsos ',Value)=1) then begin
- Delete(Value, 1, 16);
- end;
- if (pos('feliratos ',Value)=1) then begin
- Delete(Value, 1, 10);
- end;
- if (pos('nΘmafilm ',Value)=1) then begin
- Delete(Value, 1, 9);
- end;
-
- Value2:=Copy(Value,0,pos(' ',Value)-1);
- Value:=Copy(Value,pos(' ',Value)+1,Length(Value));
-
- SetField(fieldCategory, AnsiUpFirstLetter(Value));
- SetField(fieldCountry, AnsiUpFirstLetter(Value2));
- end;
-
- //actors
- LineNr := FindLine('<b>szerepl⌡(k):', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<b>szerepl⌡(k): </b><br>', Line)+24;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<hr>', Line)-1;
- Value := copy(Line, 0, EndPos);
- Value := StringReplace(Value, '<br>', #13#10);
- HTMLRemoveTags(Value);
- SetField(fieldActors, Value);
- end;
-
- //director
- LineNr := FindLine('<strong>rendez⌡: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>rendez⌡: </strong>', Line)+31;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- SetField(fieldDirector, Value);
- end;
-
- //description
- LineNr := FindLine('<b>szavazok</b></a> rß!', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<b>szavazok</b></a> rß!', Line)+23;
- Delete(Line, 1, BeginPos-1);
- BeginPos := pos('size="2">', Line)+9;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('</font>', Line)-1;
- Value := copy(Line, 0, EndPos);
- Value := StringReplace(Value, '<BR>', #13#10);
- HTMLRemoveTags(Value);
- SetField(fieldDescription, Value);
- end;
-
- //producer
- LineNr := FindLine('<strong>producer: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>producer: </strong>', Line)+32;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- SetField(fieldProducer, Value);
- end;
-
- //comments
- CommentString := '';
- //comments - screenwriter
- LineNr := FindLine('<strong>forgat≤k÷nyvφr≤: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>forgat≤k÷nyvφr≤: </strong>', Line)+39;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- if Value<>'' then
- CommentString := CommentString+'Forgat≤k÷nyvφr≤: '+Value+#13#10;
- end;
-
- //comments - writer
- LineNr := FindLine('<strong>φr≤: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>φr≤: </strong>', Line)+27;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- if Value<>'' then
- CommentString := CommentString+'═r≤: '+Value+#13#10;
- end;
-
- //comments - music
- LineNr := FindLine('<strong>zene: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>zene: </strong>', Line)+28;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- if Value<>'' then
- CommentString := CommentString+'Zene: '+Value+#13#10;
- end;
-
- //comments - cameraman
- LineNr := FindLine('<strong>operat⌡r: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>operat⌡r: </strong>', Line)+32;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- if Value<>'' then
- CommentString := CommentString+'Operat⌡r: '+Value+#13#10;
- end;
-
- //comments - costum designer
- LineNr := FindLine('<strong>jelmeztervez⌡: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>jelmeztervez⌡: </strong>', Line)+37;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- if Value<>'' then
- CommentString := CommentString+'Jelmeztervez⌡: '+Value+#13#10;
- end;
-
- //comments - cutter
- LineNr := FindLine('<strong>vßg≤: </strong>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<strong>vßg≤: </strong>', Line)+28;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('<br>', Line)-1;
- Value := copy(Line, 0, EndPos);
- HTMLRemoveTags(Value);
- if Value<>'' then
- CommentString := CommentString+'Vßg≤: '+Value+#13#10;
- end;
-
- SetField(fieldComments, CommentString);
-
- //picture
- LineNr := FindLine('<img src="/mozi/kep_film', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<img src="', Line) + 10;
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('"', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value, True); // False = do not store picture externally ; store it in the catalog file
- end;
-
- DisplayResults;
- end;
-
- Function stringReverse(S : String): String;
- Var
- i : Integer;
- Begin
- Result := '';
- For i := Length(S) DownTo 1 Do
- Begin
- Result := Result + Copy(S,i,1) ;
- End;
- End;
-
- procedure AddMoviesTitles(Page: TStringList; Tag: string);
- var
- Line: string;
- LineNr: Integer;
- MovieTitle, OriTitle, MovieAddress, Year: string;
- StartPos, EndPos: Integer;
- begin
- LineNr := FindLine(tag, Page, 0);
- if LineNr > -1 then
- begin
- PickTreeAdd('Talßlatok:', '');
- Line := Page.GetString(LineNr);
- repeat
- StartPos := pos('href="', Line) + 5;
- Delete(Line, 1, StartPos);
- MovieAddress := Copy(Line, 1, pos('" target="', Line) - 1);
- StartPos := pos('i_body=', MovieAddress) + 7;
- EndPos := pos('&i_title=', MovieAddress);
- MovieAddress:=Copy(Line, StartPos, EndPos-StartPos);
- MovieAddress:=StringReplace(MovieAddress, '@@@', '&');
- MovieAddress:=StringReplace(MovieAddress, '@@', '?');
-
- StartPos := Pos('<strong>', Line) + 8;
- MovieTitle := Copy(Line, StartPos, Pos('</strong>', Line) - StartPos);
- StartPos := Pos('</a>', Line) + 6;
- OriTitle := Copy(Line, StartPos, Pos(')</font>', Line) - StartPos);
- StartPos := Pos(') </font>', Line) - 4;
- Year := Copy(Line, StartPos, 4);
- if (Copy(Year,0,2)='19') or (Copy(Year,0,2)='20') or (Copy(Year,0,2)='21') then
- Year := Copy(Line, StartPos, 4)
- else
- Year := '';
- MovieTitle:=MovieTitle+' ('+OriTitle+'), '+Year;
- HTMLDecode(Movietitle);
- PickTreeAdd(MovieTitle, 'http://www.port.hu' + MovieAddress);
- LineNr := FindLine(tag, Page, LineNr+1);
- if LineNr > -1 then
- Line := Page.GetString(LineNr)
- else
- Line := '';
- until Line = '';
- end;
- end;
-
- begin
- if CheckVersion(3,4,0) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- if Input('Port.hu import', 'A keresend⌡ film cφme:', MovieName) then
- begin
- AnalyzePage('http://www.port.hu/pls/ci/cinema.film_list?i_film_title='+UrlEncode(MovieName));
- end;
- end else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
- end.
-
-